cmake_minimum_required(VERSION 3.14)

set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)

# 自动识别命令行传入的 ARCH / SDK
if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
    set(CMAKE_OSX_SYSROOT iphoneos)
else()
    set(CMAKE_OSX_SYSROOT iphonesimulator)
endif()

# 强制使用 clang
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)

# 必须显式给出 sysroot，否则就会链到 macOS
set(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT} CACHE STRING "SDK root" FORCE)